package com.ruoyi.logistic.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.logistic.domain.NetworkPullUniform;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.dto.NetworkPullUniformDto;
import com.ruoyi.logistic.domain.vo.NetworkPullUniformSearchVo;
import com.ruoyi.logistic.mapper.NetworkPullUniformMapper;
import com.ruoyi.logistic.service.INetworkPullUniformService;
import com.ruoyi.qualityControl.domain.vo.QcFalseSignComplainEnum;
import com.ruoyi.qualityControl.enums.NetworkPullUniformEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
@Service
public class NetworkPullUniformServiceImpl implements INetworkPullUniformService {
    @Autowired
    private NetworkPullUniformMapper networkPullUniformMapper;
    @Override
    public List<NetworkPullUniform> selectAll(PageDate pageDate) {
        PageHelper.startPage(pageDate);
        return networkPullUniformMapper.selectAll();
    }

    @Override
    public Boolean insert(NetworkPullUniformDto networkPullUniformDto) {
        networkPullUniformDto.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
        networkPullUniformDto.setCreateBy(SecurityUtils.getLoginUser().getUserId());
            return networkPullUniformMapper.insert(networkPullUniformDto);
    }

    // @Override
    // public Boolean insert(NetworkPullUniform networkPullUniform) {
    //     networkPullUniform.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
    //     networkPullUniform.setCreateBy(SecurityUtils.getLoginUser().getUserId());
    //     return networkPullUniformMapper.insert(networkPullUniform);
    // }

    @Override
    public Boolean update(NetworkPullUniform networkPullUniform) {
        networkPullUniform.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
        return networkPullUniformMapper.update(networkPullUniform);
    }

    @Override
    public Boolean deleteById(Integer id) {
        return null;
    }

    @Override
    public NetworkPullUniform findById(Integer id) {
        return null;
    }

    @Override
    public List<NetworkPullUniform> search(NetworkPullUniformSearchVo networkPullUniformSearchVo) {
        PageHelper.startPage(networkPullUniformSearchVo.getPageDate());
        return networkPullUniformMapper.search(networkPullUniformSearchVo);
    }

    @Override
    public List<TableVo> initTable() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"id","networkNameId","name","status","pullUniformObject","pullUniformDimensionality"
                ,"weightSection","excludedProvince","transportType","createBy","updateBy","createTime"
                , "updateTime","networkName","memberName","clientName"};
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(NetworkPullUniformEnum.getValue(vo.getFields()));
        }
        return list;
    }


}
